# Contributor: Danct12 <danct12@disroot.org>
# Maintainer: Danct12 <danct12@disroot.org>
pkgname=schroot
pkgver=1.6.10
pkgrel=0
pkgdesc="Allows users to execute shell commands under different root filesystems. (Successor to dchroot)."
url="https://packages.qa.debian.org/s/schroot.html"
arch="all"
license="GPL-3.0-or-later"
makedepends="autoconf automake boost-dev coreutils cppunit-dev groff gettext-dev libtool"
subpackages="$pkgname-bash-completion $pkgname-dev $pkgname-doc $pkgname-lang"
source="
	http://http.debian.net/debian/pool/main/s/schroot/schroot_$pkgver.orig.tar.xz
	http://http.debian.net/debian/pool/main/s/schroot/schroot_$pkgver-3+deb9u1.debian.tar.xz
	busybox-compat.patch
	getent.patch
	getmntent.patch
	musl.patch
	pam.d.schroot.patch
	remove-networks.patch
	schroot-cppunit.patch
	"
options="suid !check" # failing testsuite (20 out of 23 passed)

prepare() {
	default_prepare

	# shellcheck disable=SC2002
	cat "$srcdir"/debian/patches/series | while read -r p; do
		patch -p1 -i "$srcdir"/debian/patches/"$p"
	done

	# invalid sbuild_version
	sed -i "s/@sbuild_version@/$pkgver/g" sbuild/sbuild.pc.in

	./bootstrap
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-dchroot \
		--enable-lvm-snapshot \
		--enable-btrfs-snapshot \
		--with-bash-completion-dir=/usr/share/bash-completion/completions/ \
		BTRFS=/sbin/btrfs \
		BTRFSCTL=/sbin/btrfsctl \
		LVCREATE=/sbin/lvcreate \
		LVREMOVE=/sbin/lvremove
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="25155989c7811ab4c7bf3cdceaa8d0ffb12f08388143891def96fcd205f1cc401dad9a74f0e9a9ef8610d50174ff8319a8368401431dc87e1a11c0241e61fcbe  schroot_1.6.10.orig.tar.xz
5e6e3e0438151f4ce9a2a9a31c3a814091665efd17cbb050a4374d57d0f7eaf562182e2d075a014969d8a299d6b223c833267b5d7827802927cf7f317ffe54bc  schroot_1.6.10-3+deb9u1.debian.tar.xz
26fd02d3daf3a840685a1f58ffe95ecfa0405e8598eaf85484342a609d13f2c70b7393704cde5f1d85581b73269db2769ccb1d3a4744b05ed5e6675edf1f958d  busybox-compat.patch
fa37b263a59e170734bdfbb046259632baf71b809602f52d532cb3c7ea8c1b45384ebc335233fb983ee0f17e823f157dfb65e56fb511f73f4b261bcfe4fcca6f  getent.patch
21023b63665c6ab3993e8142e684b3d6086b35a15287db806a13013f5df3943383d8bb6063bc73a98d8cc548601ef89ad780e1e3a00b1bca3d239a4b217828e8  getmntent.patch
c8a87b5d03adcd13bd103a3044da84782ac11eb0d38e1a3267ea41862f5de86c03442289074d0964a861c1bc09222fc2ca60efbe8818338fb4e0583e81a22ec8  musl.patch
dcdbcb91e7960434ce2d7dc7eeea5b3bae65fa5800221c5cb6ffaf9aaaa45f9c2e0cdfdfe130de035095b2493364f1574dca73421043873adf65533f19791b8f  pam.d.schroot.patch
82542ed4db7f3e00d5531fb3af799f70502d3464db4182a128940db80675bf9b45b2e65a71c891b3b1ee6a6f8dff81c82b844ca65507f076cc54a293003e7088  remove-networks.patch
229b0be8f45099af122139511bf8137ec01074df0865e33097e8baa80002a22b2e82ce338fb62a2b50ff33c0539242798f35dd9fc5438d3ea06aefc1d94663dd  schroot-cppunit.patch"
